Skip to content

Conversation

@Enjoyzz
Copy link

@Enjoyzz Enjoyzz commented Aug 25, 2023

Allow merging deep scripts with setting merge-scripts-deep

@NicoBoos
Copy link

Hi! Can I do something to get this PR merged? I'm running into this exact issue.

My use case involves a root composer.json that merges several modular packages (e.g., module-a and module-b), each defining their own scripts. My goal is for the post-update-cmd arrays from all modules to be merged together. This would be the same behavior as merge-extra-deep.

My Setup

My root composer.json has:

{
    "name": "my-project/root",
    "extra": {
        "merge-plugin": {
            "include": [
                "modules/module-a/composer.json",
                "modules/module-b/composer.json"
            ],
            "merge-scripts": true,
            "merge-replace": false
        }
    }
}

modules/module-a/composer.json:

{
    "name": "my-project/module-a",
    "scripts": {
        "module-a:task1": "echo 'Running Task 1 from Module A'",
        "module-a:task2": "echo 'Running Task 2 from Module A'",
        "post-update-cmd": [
            "@module-a:task1",
            "@module-a:task2"
        ]
    }
}

modules/module-b/composer.json also defines its own scripts for the same event:

{
    "name": "my-project/module-b",
    "scripts": {
        "module-b:task1": "echo 'Running Task 1 from Module B'",
        "post-update-cmd": [
            "@module-b:task1"
        ]
    }
}

The Problem (Actual Behavior)

When I run composer update, only the scripts from the last module merged (module-b) are executed:

Actual result:

> echo 'Running Task 1 from Module B'

Expected Behavior

I expect the post-update-cmd arrays to be concatenated, so that scripts from all modules are executed.

Expected result:

> echo 'Running Task 1 from Module A'
> echo 'Running Task 2 from Module A'
> echo 'Running Task 1 from Module B'

Looking forward to seeing this merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants